<template>
  <div class="container">
    <p class="title">{{ $t("联系我们") }}</p>
    <div class="info-box">
      <div class="info">
        <div class="items">
          <p class="name">{{ $t("公司联系方式") }}</p>
          <p class="info">
            {{ tel.title }}：{{ tel.content }}<br />
            {{ address.title }}：{{ address.content }}
          </p>
        </div>
        <div class="items">
          <p class="name">{{ $t("服务支持-关于我们") }}</p>
          <p class="info">
            {{ kefu_tel.title }}：{{ kefu_tel.content }}<br />
            {{ service_time.title }}：{{ service_time.content }}<br />
            {{ kefu_online.title }}：{{ kefu_online.content }}<br />
            {{ online_time.title }}：{{ online_time.content }}
          </p>
        </div>
        <div class="items">
          <p class="name">{{ $t("市场合作") }}</p>
          <p class="info">
            {{ email.title }} ：<span>{{ email.content }}</span>
          </p>
        </div>
      </div>
      <baidu-map class="map" :center="center" :zoom="15" scroll-wheel-zoom>
        <bm-marker :position="center" @click="checkDetail">
          <bm-info-window :title="showTitle" :show="showFlag"></bm-info-window>
        </bm-marker>
      </baidu-map>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    contactData: {
      type: Array,
    },
  },
  data() {
    return {
      tel: {},
      address: {},
      kefu_tel: {},
      service_time: {},
      kefu_online: {},
      online_time: {},
      email: {},
      point: {},
      center: { lng: 114.071228, lat: 22.677909 },
      showTitle: "ePro易豹清洁",
      showFlag: false,
    };
  },
  fetch() {
    this.contactData.forEach((el) => {
      switch (el.tag) {
        case "tel":
          this.tel = el;
          break;
        case "address":
          this.address = el;
          break;
        case "kefu_tel":
          this.kefu_tel = el;
          break;
        case "service_time":
          this.service_time = el;
          break;
        case "kefu_online":
          this.kefu_online = el;
          break;
        case "online_time":
          this.online_time = el;
          break;
        case "email":
          this.email = el;
          break;
        case "point":
          this.center.lng = Number(el.content.split(",")[0]);
          this.center.lat = Number(el.content.split(",")[1]);
          break;
      }
    });
  },
  methods: {
    checkDetail() {
      this.showFlag = !this.showFlag;
    },
  },
};
</script>

<style lang="less" scoped>
:deep(.BMap_bubble_title) {
  font-size: 30rem;
  height: 100% !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.container {
  padding: 100rem 150rem 150rem 150rem;
  background: #fafafa;

  .title {
    font-size: 54rem;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #333333;
    text-align: center;
    margin: 0;
  }

  .info-box {
    display: flex;
    justify-content: space-between;
    margin-top: 98rem;

    .info {
      display: flex;
      flex-direction: column;
      gap: 81rem;

      .items {
        width: 600rem;
        border-bottom: 1px solid #e6e6e6;
        padding-bottom: 24rem;
        display: flex;
        flex-direction: column;
        align-items: flex-start;

        .name {
          font-size: 28rem;
          font-family: Source Han Sans CN;
          font-weight: 500;
          color: #333333;
          margin: 0;
          margin-bottom: 30rem;
        }
        .info {
          font-size: 22rem;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #333333;
          line-height: 46rem;
          margin: 0;
          flex-direction: row;
          gap: 4rem;
        }
      }
    }

    .map {
      width: 970rem;
      height: 580rem;
      border-radius: 20rem;
      overflow: hidden;
    }
  }
}
@media (max-width: 900px) {
  .container {
    padding: 0px 21px;
    background: #fff;

    .title {
      margin: 25px 0;
      font-size: 20px;
      font-family: Source Han Sans CN;
      font-weight: 500;
      color: #333333;
    }
    .info-box {
      flex-direction: column-reverse;
      padding-bottom: 20px;
      .map {
        margin-bottom: 40px;
        width: 100% !important;
        height: 420px !important;
      }
      .info {
        padding-bottom: 10px;
        .items {
          width: 100%;
          .name {
            font-size: 16px;
          }
          .info {
            font-size: 14px;
            font-family: Source Han Sans CN;
            font-weight: 400;
            color: #333333;
            line-height: 19px;
            display: flex;
            align-items: center;
            flex-direction: row;

            span {
              color: #2ca2f1;
            }
          }
        }
      }
    }
  }
}
</style>
